package br.com.webcrm.view;

import java.util.List;

import br.com.webcrm.model.QuestPergunta;

@SuppressWarnings("serial")
public class QuestPerguntaDataModel extends PrimeDataModel<QuestPergunta> {
	
	public QuestPerguntaDataModel() {
	}

	public QuestPerguntaDataModel(Object data) {
		super(data);
	}

	@SuppressWarnings("unchecked")
	@Override
    public QuestPergunta getRowData(String rowKey) {
        //In a real app, a more efficient way like a query by rowKey should be implemented to deal with huge data
        
        List<QuestPergunta> perguntas = (List<QuestPergunta>) getWrappedData();
        
        for(QuestPergunta pergunta : perguntas) {
        	String id = ""+pergunta.getIdPergunta();
            if(id.equals(rowKey))
                return pergunta;
        }
        
        return null;
    }

    @Override
    public String getRowKey(QuestPergunta pergunta) {
        return ""+pergunta.getIdPergunta();
    }

}
